//
//  LGTRWZPosrOrderViewCell.swift
//  KJLGT
//
//  Created by jenkin on 2019/9/5.
//  Copyright © 2019年 jenkin. All rights reserved.
//

import UIKit

class LGTRWZPostOrderViewCell: UITableViewCell {

    var orderStatueLabel:UILabel?
    var descLabel:UILabel?
    var clickBlock:ClickIndexBlock?
    private var _model:Dictionary<String, Any>?
    var model:Dictionary<String, Any>{
        get{
            return _model ?? Dictionary.init()
        }set{
            _model = newValue
            self.setData()
        }
    }
    
    func setData(){
        let key:String = "\(self.model["status"] as? Int ?? 0)"
        let info:Dictionary<String, Any> = LLZOrderStateInfo[key] as? Dictionary<String, Any> ?? [:]
        self.orderStatueLabel?.text = info["title"] as? String ?? ""
        self.orderStatueLabel?.textColor = info["color"] as? UIColor ?? TextColor
        self.descLabel?.text = "\(self.model["expire_time"] as? String ?? "") 内未提交审核，逾期不可提交"
    }
    
    override init(style: UITableViewCell.CellStyle, reuseIdentifier: String?) {
        super.init(style: style, reuseIdentifier: reuseIdentifier)
        self.selectionStyle = UITableViewCell.SelectionStyle.none
        let yellowBackImage:UIImageView = UIImageView.init()
        yellowBackImage.backgroundColor = YellowColor
        self.addSubview(yellowBackImage)
        yellowBackImage.snp.makeConstraints { (make) in
            make.left.right.top.equalTo(0)
            make.height.equalTo(SizeFitFloat(90))
        }
        
        let yellowCornerImage:UIImageView = LGTViewCreateUtil.share.createImageViewCorner(corner: SizeFitFloat(20))
        self.addSubview(yellowCornerImage)
        yellowCornerImage.backgroundColor = YellowColor
        yellowCornerImage.snp.makeConstraints { (make) in
            make.left.right.equalTo(0)
            make.height.equalTo(SizeFitFloat(50))
            make.top.equalTo(yellowBackImage.snp_bottomMargin).offset(-SizeFitFloat(25))
        }
        
        self.contentView.backgroundColor = ViewBackColor
        let contentBackView:UIImageView = LGTViewCreateUtil.share.createImageViewCorner(corner: SizeFitFloat(5))
        contentBackView.backgroundColor = UIColor.white
        contentBackView.isUserInteractionEnabled = true
        self.addSubview(contentBackView)
        contentBackView.snp.makeConstraints { (make) in
            make.top.equalTo(SizeFitFloat(10))
            make.left.equalTo(SizeFitFloat(6))
            make.right.equalTo(SizeFitFloat(-8))
            make.height.equalTo(SizeFitFloat(111))
            make.bottom.equalTo(SizeFitFloat(-0))
        }
        
        let lookBtn:UIButton = LGTViewCreateUtil.share.createTextLGTButton(title: "查看操作记录", font: Font_Normal_12, color: YellowColor, selectedColor: YellowColor, corner: SizeFitFloat(14), backColor: UIColor.white, borderWidth: 1, borderColor: YellowColor)
        contentBackView.addSubview(lookBtn)
        lookBtn.snp.makeConstraints { (make) in
            make.width.equalTo(SizeFitFloat(91))
            make.height.equalTo(SizeFitFloat(28))
            make.top.equalTo(SizeFitFloat(24))
            make.right.equalTo(-SizeFitFloat(12))
        }
        lookBtn.addTarget(self, action: #selector(gotoAction), for: UIControl.Event.touchUpInside)
        
        self.descLabel = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.center, textColor: GrayColor, fontSize: SizeFitFloat(12))
        contentBackView.addSubview(self.descLabel!)
        self.descLabel!.snp.makeConstraints { (make) in
            make.height.equalTo(SizeFitFloat(12))
            make.bottom.equalTo(-SizeFitFloat(24))
            make.centerX.equalTo(contentBackView)
        }
        
        self.orderStatueLabel = LGTViewCreateUtil.share.createLabel(textAlignment: NSTextAlignment.center, textColor: TextColor, fontSize: 0)
        self.orderStatueLabel?.font = Font_Bold_24
        contentBackView.addSubview(self.orderStatueLabel!)
        self.orderStatueLabel!.snp.makeConstraints { (make) in
            make.height.equalTo(SizeFit(24))
            make.centerX.equalTo(contentBackView)
            make.bottom.equalTo(self.descLabel!.snp_topMargin).offset(-SizeFitFloat(25))
        }
    }
    
    @objc func gotoAction(){
        if self.clickBlock != nil{
            self.clickBlock!(0)
        }
    }
    
    required init?(coder aDecoder: NSCoder) {
        fatalError("init(coder:) has not been implemented")
    }
    
    override func awakeFromNib() {
        super.awakeFromNib()
        // Initialization code
    }

    override func setSelected(_ selected: Bool, animated: Bool) {
        super.setSelected(selected, animated: animated)

        // Configure the view for the selected state
    }
}
